package org.rbreznak.tronco.client;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.JButton;
import javax.swing.JLabel;

public class OpeningScreen extends Screen{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private String selection = "none";
	
	private JButton btnUNIX = new JButton("UNIX Login");
	private JButton btnCARD = new JButton("WPI ID Card");
	private JButton btnNewUser = new JButton("New User");
	
	private SwipeReader cr = new SwipeReader();
	
	public OpeningScreen() {
		setLayout(new BorderLayout());
		setBackground(new Color(0,0,0));
		
		super.setLayout(new GridLayout(0,2,30,30));
		
		FormatUI.formatButton(btnUNIX);
		FormatUI.formatButton(btnCARD);
		FormatUI.formatButton(btnNewUser);
		
		add(btnUNIX);
		add(btnCARD);
		add(btnNewUser);
		
		btnUNIX.addActionListener( new ActionListener() {

			public void actionPerformed(ActionEvent arg0) {
				decideNext();
				_fireScreenUpdate();
			}
			
		});
		
		this.addKeyListener(this);
		
		this.setVisible(true);
	}
	
	public void actionPerformed(ActionEvent arg0) {

	}

	public void keyPressed(KeyEvent e) {	

	}

	public void keyReleased(KeyEvent e) {
		cr.keyReleased(e);
		
	}

	public void keyTyped(KeyEvent e) {
		cr.keyTyped(e);
	}

	@Override
	public void decideNext() {
		if(nodes.size() > 0) {
			setNext(nodes.get(0));
		}
	}
	
	@Override
	public String toString() {
		return selection;
	}

	@Override
	public void reset() {
		setNext(null);
	}
}
